package com.iseastar.guojiang.team.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.iseastar.guojiang.model.CourierTeamMonthBean;
import com.shouhuobao.station.R;

import java.util.ArrayList;

import droid.frame.activity.base.BaseAdapterExt;

/**
 * 全网战队排行
 * Created by lidandan on 2018/6/14.
 */
public class CourierAllTeamRankingListAdapter extends BaseAdapterExt<CourierTeamMonthBean> {

    public CourierAllTeamRankingListAdapter(ArrayList<CourierTeamMonthBean> items, Activity context) {
        super(items, context);
        setEmptyView(R.layout.courier_team_center_list_empty);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (hasEmptyView()) {
            return super.getView(position, convertView, parent);
        }
        ViewHolder holder = null;
        if (convertView == null || convertView.getTag() == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.courier_all_team_ranking_item, parent, false);
            holder.mTeamNameTV = (TextView) convertView.findViewById(R.id.team_name_tv);
            holder.mOrderSizeTV = (TextView) convertView.findViewById(R.id.order_size_tv);
            holder.mMileageTV = (TextView) convertView.findViewById(R.id.mileage_tv);
            holder.mRankingTV = (TextView) convertView.findViewById(R.id.ranking_tv);
            holder.mWarZoneNameTV = (TextView) convertView.findViewById(R.id.war_zone_name_tv);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        CourierTeamMonthBean item = getItem(position);
        holder.mTeamNameTV.setText(item.getTeamName());
        holder.mOrderSizeTV.setText("本月累计完成：" + item.getOrderCntTotal() + "单");
        holder.mMileageTV.setText("任务里程：" + item.getDistinceTotal() + "公里");
        holder.mRankingTV.setText((position + 1) + "");
        holder.mWarZoneNameTV.setText(item.getStoreName());
        return convertView;
    }

    class ViewHolder {
        private TextView mTeamNameTV;
        private TextView mOrderSizeTV;
        private TextView mMileageTV;
        private TextView mRankingTV;
        private TextView mWarZoneNameTV;

    }
}
